package io.github.iogogogo.redis;

import io.github.iogogogo.redis.util.RedisTemplateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * Created by tao.zeng on 2024/11/17.
 */
@Slf4j
@Component
public class RedisHandler<K, V> {

    private final StringRedisTemplate stringRedisTemplate;

    private final StringRedisTemplate bizCommonsStringRedisTemplate;

    public RedisHandler(StringRedisTemplate stringRedisTemplate, StringRedisTemplate bizCommonsStringRedisTemplate) {
        this.stringRedisTemplate = stringRedisTemplate;
        this.bizCommonsStringRedisTemplate = bizCommonsStringRedisTemplate;
    }

    public RedisTemplateUtils<K, V> getGlobalRedisTemplate() {
        return (RedisTemplateUtils<K, V>) new RedisTemplateUtils<>(bizCommonsStringRedisTemplate);
    }

    public RedisTemplateUtils<K, V> getBizRedisTemplate() {
        return (RedisTemplateUtils<K, V>) new RedisTemplateUtils<>(stringRedisTemplate);
    }
}
